$(function () {

    var productId = getQueryString('productId');
    var productUrl = '/o2o/frontend/listproductdetailpageinfo?productId=' + productId;

    $.getJSON(productUrl,
        function (data) {
            if (data.success) {
                var product = data.product;
                $('#product-img').attr('src', product.imgAddr);
                $('#product-time').text(new Date(product.lastEditTime)
                    .Format('yyyy-MM-dd'));
                if (product.point != undefined) {
                    $('#product-point').text('购买可得' + product.point + '积分');
                }
                $('#product-name').text(product.productName);
                $('#product-desc').text(product.productDesc);

                var imageAddrHtml = '';
                product.productImgList.map(function (item, index) {
                    imageAddrHtml += '<div class="card-header color-white no-border no-padding"><img src="'
                        + item.imgAddr + '"/></div>';
                });
                // todo 生成购买商品的二维码供商家扫描

                $('#imgList').html(imageAddrHtml);
            }
        });

    $('#me').click(function () {
        $.openPanel('#panel-right-demo');
    });

    $.init();

})